******************************************************************************
* Replication for "Determinants of subnational development cooperation" 
*
  ** Replication file **
  ** bernhard.reinsberg@glasgow.ac.uk **  
******************************************************************************

* Cross-sectional data
******************************************************************************

  use "JEPP_replication", clear 
  
  g brx=brussels>0
  lab var brx "Brussels office"
  g sec=nsec>0
  lab var sec "Secessionist party"
  
  g anyprg=programs>0
  replace anyprg=. if website==. 
  lab var anyprg "Aid program"
  
  encode ccode, g(cid)

  global para rai language1 sec 
  global econ rci2019 netmig unemprate
  global int brx border lnpop
  global pol eqi2013 lngdp gdppc_index 
  global C creationunit island
 
  
* Descriptive information  
  
  ** Table 1 **
  qui estpost su website agency anyprg $para $econ $pol $int $C
  esttab ., cells("count mean sd min max") noobs
   
  
* Main tests
************ 

  mat F=J(3,4,0)
  local m=1
  foreach y in website agency anyprg {
    qui probit `y' $para $C, vce(cl cid)
     est store a`m'1
	 qui test $para
	 mat F[`m',1]=r(p)
    qui probit `y' $para $econ $C, vce(cl cid)
     est store a`m'2
	 qui test $para
	 mat F[`m',2]=r(p)
    qui probit `y' $para $pol $C, vce(cl cid)
     est store a`m'3
	 qui test $para
	 mat F[`m',3]=r(p)
    qui probit `y' $para $int $C, vce(cl cid)
     est store a`m'4
	 qui test $para
	 mat F[`m',4]=r(p)
	local m=`m'+1
  }
  
  ** Table 2 **
  estout a1*, title("Determinants of regional aid website") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stats(N r2_p, fmt(0 3))
  mat li F

  
* Post-estimation descriptives 
  
  corr $para
  
  ** Figure B1 **
  est restore a14
  margins, at(rai=(0(1)25)) vce(unconditional)
  marginsplot, scheme(s1mono) title(" ") 
 
  margins, at(rai=(13.6 20.6)) vce(unconditional)
 
  margins, at(language1=(0 1)) vce(unconditional)
  
  margins, at(sec=(0 1)) vce(unconditional)


* Robustness tests
******************

* Descriptive information

  ** Table A1 **
  order ccode rcode 
  edit ccode rcode region website agency anyprg 


* Main models with other outcomes 

  ** Table B1 **
  estout a2*, title("Determinants of regional aid agency") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stats(N r2_p, fmt(0 3))
  mat li F
  
  ** Table B2 **
  estout a3*, title("Determinants of regional aid strategy") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stats(N r2_p, fmt(0 3))
  mat li F
  
  
* Linear probability models 

  local m=1
  foreach y in website agency anyprg{
    qui reg `y' $para $C, vce(cl cid)
    est store l`m'1
	 qui test $para
	 mat F[`m',1]=r(p)
    qui reg `y' $para $econ $C, vce(cl cid)
    est store l`m'2
	 qui test $para
	 mat F[`m',1]=r(p)
    qui reg `y' $para $pol $C, vce(cl cid)
    est store l`m'3
	 qui test $para
	 mat F[`m',1]=r(p)
    qui reg `y' $para $int $P $C, vce(cl cid)
    est store l`m'4
	 qui test $para
	 mat F[`m',1]=r(p)
	local m=`m'+1
  }
  
  ** Table B3 **
  estout l1*, title("Determinants of regional aid website") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stats(N r2_a, fmt(0 3))
  
  ** Table B4 **
  estout l2*, title("Determinants of regional aid agency") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stats(N r2_a, fmt(0 3))
  
  ** Table B5 **
  estout l3*, title("Determinants of regional aid programs") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stats(N r2_a, fmt(0 3))
  mat li F
  
  
* Fixed effects 
  
  xtset cid rid 
  local m=1
  
  foreach y in website agency anyprg{
    qui reg `y' $para $C i.cid, vce(cl cid)
	est store fe`m'1
	 qui test $para
	 mat F[`m',1]=r(p)
	qui reg `y' $para $econ $C i.cid, vce(cl cid)
	est store fe`m'2
	qui test $para
	 mat F[`m',1]=r(p)
	qui reg `y' $para $pol $C i.cid, vce(cl cid)
	est store fe`m'3
	 qui test $para
	 mat F[`m',1]=r(p)
	qui reg `y' $para $int $C i.cid, vce(cl cid)
	est store fe`m'4
	 qui test $para
	 mat F[`m',1]=r(p)
	local m=`m'+1
	di "`m'"
  }	
  
  ** Table B6 **
  estout fe1*, title("Determinants of regional aid website") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_* *cid*) stats(N r2_a, fmt(0 3))
  
  ** Table B7 **
  estout fe2*, title("Determinants of regional aid agency") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_* *cid*) stats(N r2_a, fmt(0 3))
  
  ** Table B8 **
  estout fe3*, title("Determinants of regional aid program") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_* *cid*) stats(N r2_a, fmt(0 3))
  mat li F
  
  
* Probit model on the within-country sample 

  egen Nwebsite=sum(website), by(cid)
  tab Nwebsite
  local m=1
  
  foreach y in website agency anyprg{
  qui probit `y' $para $C if Nwebsite>0, vce(cl cid)
  est store rs`m'1
   qui test $para
   mat F[`m',1]=r(p)
  qui probit `y' $para $econ $C if Nwebsite>0, vce(cl cid)
  est store rs`m'2
   qui test $para
   mat F[`m',2]=r(p)
  qui probit `y' $para $pol $C if Nwebsite>0, vce(cl cid)
  est store rs`m'3
   qui test $para
   mat F[`m',3]=r(p)
  qui probit `y' $para $int $C if Nwebsite>0, vce(cl cid)
  est store rs`m'4
   qui test $para
   mat F[`m',4]=r(p)
   local m=`m'+1
  }
  
  ** Table B9 **
  estout rs1*, title("Determinants of regional website") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stats(N r2_p, fmt(0 3))
  
  ** Table B10 **
  estout rs2*, title("Determinants of regional agency") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stats(N r2_p, fmt(0 3))
  
  ** Table B11 **
  estout rs3*, title("Determinants of regional program") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stats(N r2_p, fmt(0 3))
  mat li F
  
  
* Multi-level models 

  local m=1
  
  foreach y in website agency anyprg{
    qui meprobit `y' $para $C || cid:, vce(cl cid) iterate(33)
	est store me`m'1
	 qui test $para
	 mat F[`m',1]=r(p)
	qui meprobit `y' $para $econ $C || cid:, vce(cl cid) iterate(33)
	est store me`m'2
	 qui test $para
	 mat F[`m',2]=r(p)
	qui meprobit `y' $para $pol $C || cid:, vce(cl cid) iterate(33)
	est store me`m'3
	 qui test $para
	 mat F[`m',3]=r(p)
	qui meprobit `y' $para $int $C || cid:, vce(cl cid) iterate(33)
	est store me`m'4
	 qui test $para
	 mat F[`m',4]=r(p)
	di "`m'"
	local m=`m'+1
  }	
  
  ** Table B12 **
  estout me1*, title("Determinants of regional aid website") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stats(N ll converged, fmt(0 3 0))
  
  ** Table B13 **
  estout me2*, title("Determinants of regional aid agency") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stats(N ll converged, fmt(0 3 0))
  
  ** Table B14 **
  estout me3*, title("Determinants of regional aid strategy") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stats(N ll converged, fmt(0 3 0))
  mat li F
  
   
* Other control variables from the literature 

  g lnpopden=ln(pop/arearegion)
  global TT2014 rai lnpop lnpopden gdppc language1 
  global T2015 rai lnpop eqi2013 brussels
  global DB2013 lngdp gdppc_index shared self regpar3 
  global BHT2018 crosscut shared self language1 lnpop lnpopden gdppc
  
  qui probit website rai language1 sec shared crosscut gdppc lnpop lnpopden, vce(cl cid) iterate(100) difficult
   est store cv01
   qui test rai language1 sec
   mat F[1,1]=r(p)
  qui probit website rai language1 sec shared lngdp gdppc_index, vce(cl cid) 
   est store cv02
   qui test rai language1 sec 
   mat F[1,2]=r(p)
  qui probit website rai language1 sec gdppc lnpop lnpopden, vce(cl cid) 
   est store cv03
   qui test rai language1 sec 
   mat F[1,3]=r(p)
  qui probit website rai language1 sec lnpop eqi2013 brussels, vce(cl cid) 
   est store cv04
   qui test rai language1 sec 
   mat F[1,4]=r(p)

  ** Table B15 ** 
  estout cv0*, title("Determinants of regional aid website") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stats(N r2_p converged, fmt(0 3 0))
  mat li F
  
  
* Alternative region-level controls 

  qui probit website $para crosscut nn_rr nr_rr $C, vce(cl cid)
   est store cv11
   qui test $para 
   mat F[1,1]=r(p)
  qui probit website rai language1 regpar3 $C, vce(cl cid)
   est store cv12
   qui test rai language regpar3
   mat F[1,1]=r(p)
  qui probit website $para lnpopden $C, vce(cl cid)
   est store cv13
   qui test $para 
   mat F[1,1]=r(p)
  qui probit website $para snaid_prev $C, vce(cl cid)
   est store cv14
   qui test $para 
   mat F[1,1]=r(p)
   
  ** Table B16 ** 
  estout cv1*, title("Determinants of regional aid website") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stats(N r2_p converged, fmt(0 3 0))
  mat li F    
    
   
* Additional country controls

  qui meprobit website $para $C s_dis ||cid: , vce(cl cid) iterate(33)
   est store cv21
   qui test $para
   mat F[1,1]=r(p)
  qui meprobit website $para $C role_prop ||cid:, vce(cl cid) iterate(33)
   est store cv22
   qui test $para
   mat F[1,2]=r(p)
  qui meprobit website $para $C s_dis role_prop ||cid:, vce(cl cid) iterate(33)
   est store cv23
   qui test $para
   mat F[1,3]=r(p)
 
  ** Table B17 **
  estout cv2*, title("Determinants of regional aid website") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stats(N ll converged, fmt(0 3 0))
  mat li F   
  
  
  
* Time-series cross-sectional data
**********************************  

  use "JEPP_TSCS_replication", clear
  xtset rcode year 

  
* Data and variables

  g t1=t
  g t2=0.01*(4*t^2-2)
  g t3=0.001*(8*t^3-12*t)
  g T=(year-1949)/70
  
  qui xi:reg t i.cid i.rcode
  
  global Z t1 t2 t3 T
  

* One-year panel
  
  local m=1
  foreach y in agency anyaid dv{
    qui reg `y' l.rai l.sec $Z _Icid*, vce(cl cid)
    est store m`m'
    qui reg `y' l.rai l.sec $Z _Irc*, vce(cl cid)
    est store n`m'
	local m=`m'+1
    }

  ** Table 3 ** 	
  estout m1 m3 n1 n3, title("Determinants of agency") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_* *cid*) stats(N r2_a, fmt(0 3))
  
   
* Three-year panel

preserve

  g period=.
  forvalues i=1/25{
   replace period=`i' if year>=1949+3*(`i'-1) & year<1952+3*(`i'-1)
   }
   
  collapse (max)agency dv anyaid  t1 t2 t3  secany rai, by(ccode cid rcode period) 
  
  xtset rcode period
  
  local m=1
  foreach y in agency anyaid dv{
    qui reg `y' l.rai l.secany t1 t2 t3 period i.cid, ro cl(cid)
	est store fe1`m'
	qui reg `y' l.rai l.secany t1 t2 t3 i.period i.cid, ro cl(cid)
	est store fe2`m'
	qui reg `y' l.rai l.secany t1 t2 t3 period i.rcode, ro cl(cid)
	est store fe3`m'
	local m=`m'+1
  }
  
  ** Table B18 **
  estout fe11 fe13 fe31 fe33, title("Time-to-event panel analysis") note("Significance levels: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_* *cid* *rcode*) stats(N r2_a, fmt(0 3))
  
restore  
  
* Descriptive statistics
  
  ** Table B19 **
  qui estpost su agency dv rai secany creation if dv!=.
  esttab ., cells("count mean sd min max") noobs
    
  

